Skip to content

feat: add import from Bedrock Agents to add agent and create flows#563

Open
tejaskash wants to merge 5 commits intomainfrom
feature/import-from-bedrock-agents
Open

feat: add import from Bedrock Agents to add agent and create flows#563
tejaskash wants to merge 5 commits intomainfrom
feature/import-from-bedrock-agents

Conversation

@tejaskash
Copy link
Contributor

@tejaskash tejaskash commented Mar 18, 2026

Summary

  • Adds "Import from Bedrock Agents" as a third option in the add agent and create flows
  • Fetches a Bedrock Agent's full configuration (action groups, knowledge bases, multi-agent collaboration, code interpreter, guardrails, prompt overrides, memory) via AWS SDK and translates it into runnable Python code
  • Supports both Strands and LangChain/LangGraph frameworks
  • Works in both interactive TUI and non-interactive CLI (--type import --agent-id X --agent-alias-id Y --region us-east-1)
  • Generated code uses standard BedrockAgentCoreApp() + @app.entrypoint pattern, deployable via agentcore deploy
  • No CDK changes required; import produces standard agentcore.json entries

New files

  • src/cli/aws/bedrock-import.ts + bedrock-import-types.ts — AWS SDK wrapper for Bedrock Agent APIs
  • src/cli/operations/agent/import/ — base translator, Strands translator, LangGraph translator, pyproject generator, constants, shared handler

Test plan

  • 25 new unit tests (AWS client, both translators, pyproject generation, import validation)
  • All 2243 unit tests pass
  • ESLint clean on all changed files
  • TypeScript compiles cleanly
  • End-to-end verified: imported a real Bedrock Agent with knowledge bases, agentcore dev starts and processes requests successfully

Manual testing steps

Tested against Bedrock Agent LDGEKNWZQC (alias TSTALIASID) in account 637423344544, region us-east-1. This agent has a knowledge base for Git integration support.

1. Create project and import agent (non-interactive CLI)

mkdir /tmp/import-test && cd /tmp/import-test
agentcore create --name gitsupport --type import \
  --agent-id LDGEKNWZQC --agent-alias-id TSTALIASID \
  --region us-east-1 --framework Strands --memory none

2. Verify generated code

  • app/gitsupport/main.py contains correct Strands agent with KB tool (retrieve_knowledge_base_quick_start_bc5jc), @app.entrypoint, and BedrockAgentCoreApp()
  • agentcore/agentcore.json has the agent entry with "protocol": "HTTP", "modelProvider": "Bedrock", no memories (matches --memory none)
  • No memory retrieval code in main.py (correct for --memory none since agentcore.json has no strategies)

3. Dev server

cd /tmp/import-test/gitsupport
agentcore dev

Server starts on http://localhost:8080/invocations.

4. Invoke
Sent prompt: "How do I set up a CodeConnection to GitHub?"

  • Agent called the KB tool, queried the Bedrock knowledge base, and returned a detailed step-by-step answer
  • Response included tools_used: ["retrieve_knowledge_base_quick_start_bc5jc"]
  • Full request/response cycle completed successfully

Memory strategy fix (166397a)

Fixed actor_id parameter missing from retrieve_memories calls in the Strands translator, and aligned both translators' memory retrieval code with the strategies written to agentcore.json:

  • shortTerm (no strategies in schema) — no namespace-specific retrieval
  • longAndShortTerm (SEMANTIC + USER_PREFERENCE + SUMMARIZATION) — retrieves from all three namespaces (/users/{user_id}/facts, /users/{user_id}/preferences, /summaries/{user_id}/)

Adds a third option in the "add agent" flow that fetches a Bedrock Agent's
configuration via AWS SDK and translates it into runnable Strands or
LangChain/LangGraph Python code, wired into the standard AgentCore project
structure.

Supports action groups, knowledge bases, multi-agent collaboration, code
interpreter, guardrails, prompt overrides, and memory configuration. Both
interactive TUI and non-interactive CLI paths are implemented.
@tejaskash tejaskash requested a review from a team March 18, 2026 22:28
@github-actions github-actions bot added the size/xl PR size: XL label Mar 18, 2026
@tejaskash tejaskash changed the title feat: add Import from Bedrock Agents feat: add Import from Bedrock Agents to add agent and create flows Mar 18, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 44.38% 4450 / 10025
🔵 Statements 43.98% 4704 / 10694
🔵 Functions 45.67% 830 / 1817
🔵 Branches 44.84% 2936 / 6547
Generated in workflow #1019 for commit 7c08566 by the Vitest Coverage Report Action

@tejaskash tejaskash changed the title feat: add Import from Bedrock Agents to add agent and create flows feat: add import from Bedrock Agents to add agent and create flows Mar 18, 2026
@github-actions github-actions bot added size/xl PR size: XL and removed size/xl PR size: XL labels Mar 18, 2026
@tejaskash
Copy link
Contributor Author

Code review

Found 1 issue:

  1. Missing actor_id parameter in Strands translator's retrieve_memories call. The LangGraph translator includes actor_id=user_id but the Strands translator omits it, creating an inconsistency between the two framework implementations. If the AgentCore memory API requires or uses actor_id for filtering, the Strands path will return incorrect results or fail at runtime.

? [
' memories = memory_client.retrieve_memories(memory_id=memory_id, namespace=f\'/summaries/{user_id}/\', query="Retrieve the most recent session summaries.", top_k=20)',
' memory_synopsis = "\\n".join([m.get("content", {}).get("text", "") for m in memories])',

Compare with the LangGraph translator which correctly includes it:

? `
memories = memory_client.retrieve_memories(memory_id=memory_id, namespace=f'/summaries/{user_id}/', query="Retrieve the most recent session summaries.", actor_id=user_id, top_k=20)
memory_synopsis = "\\n".join([m.get("content", {}).get("text", "") for m in memories])`

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

- Add actor_id=user_id to all retrieve_memories calls (was missing in
  Strands translator)
- Pass memoryOption through to translators so generated Python code
  matches the strategies written to agentcore.json
- shortTerm: no namespace-specific retrieval (no strategies in schema)
- longAndShortTerm: retrieve from all three strategy namespaces
  (/users/{user_id}/facts, /users/{user_id}/preferences,
  /summaries/{user_id}/) matching SEMANTIC, USER_PREFERENCE, and
  SUMMARIZATION strategies
@github-actions github-actions bot added size/xl PR size: XL and removed size/xl PR size: XL labels Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xl PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant